package com.xbkj.pgrp.server.handler;

import com.xbkj.pgrp.server.model.app.Role;
import org.springframework.stereotype.Service;
import xyz.erupt.annotation.fun.ChoiceFetchHandler;
import xyz.erupt.annotation.fun.VLModel;
import xyz.erupt.jpa.dao.EruptDao;

import javax.annotation.Resource;
import java.util.List;
@Service
public class RoleHandler implements ChoiceFetchHandler {

    @Resource
    private EruptDao eruptDao;

    @Override
    public List<VLModel> fetch(String[] params) {
        try {
            return eruptDao.lambdaQuery(Role.class).list().stream().map(role -> new VLModel(role.getId(), role.getRoleName())).toList();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return List.of();
    }
}
